/*
**==============================================================================
**
** Copyright (c) Microsoft Corporation. All rights reserved. See file LICENSE
** for license information.
**
**==============================================================================
*/

#include <MI.h>
#include <common/linux/sal.h>
#include "strings.h"

#define MI_STR_ID_UNKNOWN_PRAGMA                    MI_STR(STR_ID_UNKNOWN_PRAGMA)
#define MI_STR_ID_CLASS_ALREADY_DEFINED        	    MI_STR(STR_ID_CLASS_ALREADY_DEFINED)
#define MI_STR_ID_UNDEFINED_SUPERCLASS        	    MI_STR(STR_ID_UNDEFINED_SUPERCLASS)
#define MI_STR_ID_CLASS_FEATURE_ALREADY_DEFINED     MI_STR(STR_ID_CLASS_FEATURE_ALREADY_DEFINED)
#define MI_STR_ID_DUPLICATE_QUALIFIER        	    MI_STR(STR_ID_DUPLICATE_QUALIFIER)
#define MI_STR_ID_UNDEFINED_QUALIFIER        	    MI_STR(STR_ID_UNDEFINED_QUALIFIER)
#define MI_STR_ID_MISSING_QUALIFIER_INITIALIZER     MI_STR(STR_ID_MISSING_QUALIFIER_INITIALIZER)
#define MI_STR_ID_INVALID_QUALIFIER_INITIALIZER     MI_STR(STR_ID_INVALID_QUALIFIER_INITIALIZER)
#define MI_STR_ID_INVALID_INITIALIZER        	    MI_STR(STR_ID_INVALID_INITIALIZER)
#define MI_STR_ID_UNDEFINED_CLASS        	    MI_STR(STR_ID_UNDEFINED_CLASS)
#define MI_STR_ID_IGNORED_INITIALIZER        	    MI_STR(STR_ID_IGNORED_INITIALIZER)
#define MI_STR_ID_PARAMETER_ALREADY_DEFINED         MI_STR(STR_ID_PARAMETER_ALREADY_DEFINED)
#define MI_STR_ID_ILLEGAL_ARRAY_SUBSCRIPT           MI_STR(STR_ID_ILLEGAL_ARRAY_SUBSCRIPT)
#define MI_STR_ID_INCOMPATIBLE_FLAVORS              MI_STR(STR_ID_INCOMPATIBLE_FLAVORS)
#define MI_STR_ID_INITIALIZER_OUT_OF_RANGE          MI_STR(STR_ID_INITIALIZER_OUT_OF_RANGE)
#define MI_STR_ID_INTERNAL_ERROR        	    MI_STR(STR_ID_INTERNAL_ERROR)
#define MI_STR_ID_QUALIFIER_ALREADY_DECLARED        MI_STR(STR_ID_QUALIFIER_ALREADY_DECLARED)
#define MI_STR_ID_WRONG_TYPE_FOR_QUALIFIER          MI_STR(STR_ID_WRONG_TYPE_FOR_QUALIFIER)
#define MI_STR_ID_OUT_OF_MEMORY        	    MI_STR(STR_ID_OUT_OF_MEMORY)
#define MI_STR_ID_ILLEGAL_QUALIFIER_OVERRIDE        MI_STR(STR_ID_ILLEGAL_QUALIFIER_OVERRIDE)
#define MI_STR_ID_KEY_MUTATION_ERROR        	    MI_STR(STR_ID_KEY_MUTATION_ERROR)
#define MI_STR_ID_KEY_TYPE_MUTATION_ERROR           MI_STR(STR_ID_KEY_TYPE_MUTATION_ERROR)
#define MI_STR_ID_KEY_STRUCTURE_MUTATION_ERROR      MI_STR(STR_ID_KEY_STRUCTURE_MUTATION_ERROR)
#define MI_STR_ID_UNKNOWN_QUALIFIER                 MI_STR(STR_ID_UNKNOWN_QUALIFIER)
#define MI_STR_ID_ILLEGAL_SCOPE_FOR_QUALIFIER       MI_STR(STR_ID_ILLEGAL_SCOPE_FOR_QUALIFIER)
#define MI_STR_ID_PROPERTY_CONSTRAINT_FAILURE       MI_STR(STR_ID_PROPERTY_CONSTRAINT_FAILURE)
#define MI_STR_ID_PROPERTY_QUALIFIER_INCOMPATIBLE   MI_STR(STR_ID_PROPERTY_QUALIFIER_INCOMPATIBLE)
#define MI_STR_ID_OVERRIDE_QUALIFIER_NAME_MISMATCH  MI_STR(STR_ID_OVERRIDE_QUALIFIER_NAME_MISMATCH)
#define MI_STR_ID_UNDEFINED_CLASS_IN_EMBEDDEDINSTANCE_QUALIFIER     MI_STR(STR_ID_UNDEFINED_CLASS_IN_EMBEDDEDINSTANCE_QUALIFIER)
#define MI_STR_ID_UNTERMINATED_STRING_LITERAL       MI_STR(STR_ID_UNTERMINATED_STRING_LITERAL)
#define MI_STR_ID_ILLEGAL_HEX_CHARACTER        	    MI_STR(STR_ID_ILLEGAL_HEX_CHARACTER)
#define MI_STR_ID_INTEGER_OVERFLOW        	    MI_STR(STR_ID_INTEGER_OVERFLOW)
#define MI_STR_ID_ILLEGAL_BINARY_LITERAL            MI_STR(STR_ID_ILLEGAL_BINARY_LITERAL)
#define MI_STR_ID_MOF_STACK_OVERFLOW        	    MI_STR(STR_ID_MOF_STACK_OVERFLOW)
#define MI_STR_ID_MOF_STACK_UNDERFLOW        	    MI_STR(STR_ID_MOF_STACK_UNDERFLOW)
#define MI_STR_ID_FAILED_TO_READ_INCLUDE_FILE       MI_STR(STR_ID_FAILED_TO_READ_INCLUDE_FILE)
#define MI_STR_ID_SYNTAX_ERROR                      MI_STR(STR_ID_SYNTAX_ERROR)
#define MI_STR_ID_PARSER_STACK_OVERFLOW             MI_STR(STR_ID_PARSER_STACK_OVERFLOW)
#define MI_STR_ID_STREAM_QUALIFIER_ON_NON_ARRAY     MI_STR(STR_ID_STREAM_QUALIFIER_ON_NON_ARRAY)
#define MI_STR_ID_STREAM_QUALIFIER_ON_NON_OUTPUT    MI_STR(STR_ID_STREAM_QUALIFIER_ON_NON_OUTPUT)
#define MI_STR_ID_UNDEFINED_PROPERTY                MI_STR(STR_ID_UNDEFINED_PROPERTY)
#define MI_STR_ID_ERROR_DETAILS                     MI_STR(STR_ID_ERROR_DETAILS)
#define MI_STR_ID_ERROR_DETAILS_INCLUDED_FILE       MI_STR(STR_ID_ERROR_DETAILS_INCLUDED_FILE)
#define MI_STR_ID_ERROR_DETAILS_CONTENT             MI_STR(STR_ID_ERROR_DETAILS_CONTENT)
#define MI_STR_ID_UNDEFINED_INSTANCE_ALIAS          MI_STR(STR_ID_UNDEFINED_INSTANCE_ALIAS)
#define MI_STR_ID_CONVERT_PROPERTY_VALUE_FAILED     MI_STR(STR_ID_CONVERT_PROPERTY_VALUE_FAILED)
#define MI_STR_ID_MI_CREATEINSTANCE_FAILED          MI_STR(STR_ID_MI_CREATEINSTANCE_FAILED)
#define MI_STR_ID_MI_SET_PROPERTY_FAILED            MI_STR(STR_ID_MI_SET_PROPERTY_FAILED)
#define MI_STR_ID_MI_ADD_PROPERTY_FAILED            MI_STR(STR_ID_MI_ADD_PROPERTY_FAILED)
#define MI_STR_ID_ALIAS_DECL_ALREADY_DEFINED        MI_STR(STR_ID_ALIAS_DECL_ALREADY_DEFINED)

#define MI_STR_ID_SYNTAX_ERROR_INVALID_ALIAS_DECL   MI_STR(STR_ID_SYNTAX_ERROR_INVALID_ALIAS_DECL)
#define MI_STR_ID_SYNTAX_ERROR_INVALID_COMMENT      MI_STR(STR_ID_SYNTAX_ERROR_INVALID_COMMENT)
#define MI_STR_ID_SYNTAX_ERROR_INVALID_TOKEN        MI_STR(STR_ID_SYNTAX_ERROR_INVALID_TOKEN)
#define MI_STR_ID_SYNTAX_ERROR_INCOMPLETE_STRING_VALUE  MI_STR(STR_ID_SYNTAX_ERROR_INCOMPLETE_STRING_VALUE)
#define MI_STR_ID_SYNTAX_ERROR_INVALID_CHAR16_VALUE     MI_STR(STR_ID_SYNTAX_ERROR_INVALID_CHAR16_VALUE)
#define MI_STR_ID_SYNTAX_ERROR_INVALID_ESCAPED_CHAR16_VALUE     MI_STR(STR_ID_SYNTAX_ERROR_INVALID_ESCAPED_CHAR16_VALUE)
#define MI_STR_ID_SYNTAX_ERROR_INVALID_ESCAPED_CHAR     MI_STR(STR_ID_SYNTAX_ERROR_INVALID_ESCAPED_CHAR)
#define MI_STR_ID_SYNTAX_ERROR_INCOMPLETE_ESCAPED_CHAR16_VALUE  MI_STR(STR_ID_SYNTAX_ERROR_INCOMPLETE_ESCAPED_CHAR16_VALUE)
#define MI_STR_ID_SYNTAX_ERROR_INVALID_NUMBER_VALUE     MI_STR(STR_ID_SYNTAX_ERROR_INVALID_NUMBER_VALUE)

#define MI_STR_ID_CREATE_PARSER_FAILED              MI_STR(STR_ID_CREATE_PARSER_FAILED)

#define MI_STR_ID_PARAMETER_INVALID_OPTIONS_VALUE              MI_STR(STR_ID_PARAMETER_INVALID_OPTIONS_VALUE)
#define MI_STR_ID_PARAMETER_INVALID_VALUE_STRING               MI_STR(STR_ID_PARAMETER_INVALID_VALUE_STRING)
#define MI_STR_ID_PARAMETER_INVALID_VALUE_NULL                 MI_STR(STR_ID_PARAMETER_INVALID_VALUE_NULL)
#define MI_STR_ID_PARAMETER_INVALID_VALUE_UNEXPECTED_INTEGER   MI_STR(STR_ID_PARAMETER_INVALID_VALUE_UNEXPECTED_INTEGER)
#define MI_STR_ID_PARAMETER_INVALID_VALUE_OUT_OF_RANGE_INTEGER MI_STR(STR_ID_PARAMETER_INVALID_VALUE_OUT_OF_RANGE_INTEGER)
#define MI_STR_ID_PARAMETER_INVALID_BUFFER                     MI_STR(STR_ID_PARAMETER_INVALID_BUFFER)

#define MI_STR_ID_MI_CREATECLASS_FAILED             MI_STR(STR_ID_MI_CREATECLASS_FAILED)

#define MI_STR_ID_PARAMETER_UNEXPECTED_RESULTCLASSCOUNT        MI_STR(STR_ID_PARAMETER_UNEXPECTED_RESULTCLASSCOUNT)
#define MI_STR_ID_PARAMETER_UNEXPECTED_RESULTINSTANCECOUNT     MI_STR(STR_ID_PARAMETER_UNEXPECTED_RESULTINSTANCECOUNT)

#define MI_STR_ID_INVALID_EMBEDDEDPROPERTYVALUE_WRONG_TYPE     MI_STR(STR_ID_INVALID_EMBEDDEDPROPERTYVALUE_WRONG_TYPE)

#define MI_STR_ID_INITIALIZER_OUT_OF_RANGE_DATETIMEVALUE       MI_STR(STR_ID_INITIALIZER_OUT_OF_RANGE_DATETIMEVALUE)

MI_CONST MI_Char * cSTRS[]=
{
    MI_STR_ID_UNKNOWN_PRAGMA,
    MI_STR_ID_CLASS_ALREADY_DEFINED,
    MI_STR_ID_UNDEFINED_SUPERCLASS,
    MI_STR_ID_CLASS_FEATURE_ALREADY_DEFINED,
    MI_STR_ID_DUPLICATE_QUALIFIER,
    MI_STR_ID_UNDEFINED_QUALIFIER,
    MI_STR_ID_MISSING_QUALIFIER_INITIALIZER,
    MI_STR_ID_INVALID_QUALIFIER_INITIALIZER,
    MI_STR_ID_INVALID_INITIALIZER,
    MI_STR_ID_UNDEFINED_CLASS,
    MI_STR_ID_IGNORED_INITIALIZER,
    MI_STR_ID_PARAMETER_ALREADY_DEFINED,
    MI_STR_ID_ILLEGAL_ARRAY_SUBSCRIPT,
    MI_STR_ID_INCOMPATIBLE_FLAVORS,
    MI_STR_ID_INITIALIZER_OUT_OF_RANGE,
    MI_STR_ID_INTERNAL_ERROR,
    MI_STR_ID_QUALIFIER_ALREADY_DECLARED,
    MI_STR_ID_WRONG_TYPE_FOR_QUALIFIER,
    MI_STR_ID_OUT_OF_MEMORY,
    MI_STR_ID_ILLEGAL_QUALIFIER_OVERRIDE,
    MI_STR_ID_KEY_MUTATION_ERROR,
    MI_STR_ID_KEY_TYPE_MUTATION_ERROR,
    MI_STR_ID_KEY_STRUCTURE_MUTATION_ERROR,
    MI_STR_ID_UNKNOWN_QUALIFIER,
    MI_STR_ID_ILLEGAL_SCOPE_FOR_QUALIFIER,
    MI_STR_ID_PROPERTY_CONSTRAINT_FAILURE,
    MI_STR_ID_PROPERTY_QUALIFIER_INCOMPATIBLE,
    MI_STR_ID_OVERRIDE_QUALIFIER_NAME_MISMATCH,
    MI_STR_ID_UNDEFINED_CLASS_IN_EMBEDDEDINSTANCE_QUALIFIER,
    MI_STR_ID_UNTERMINATED_STRING_LITERAL,
    MI_STR_ID_ILLEGAL_HEX_CHARACTER,
    MI_STR_ID_INTEGER_OVERFLOW,
    MI_STR_ID_ILLEGAL_BINARY_LITERAL,
    MI_STR_ID_MOF_STACK_OVERFLOW,
    MI_STR_ID_MOF_STACK_UNDERFLOW,
    MI_STR_ID_FAILED_TO_READ_INCLUDE_FILE,
    MI_STR_ID_SYNTAX_ERROR,
    MI_STR_ID_PARSER_STACK_OVERFLOW,
    MI_STR_ID_STREAM_QUALIFIER_ON_NON_ARRAY,
    MI_STR_ID_STREAM_QUALIFIER_ON_NON_OUTPUT,
    MI_STR_ID_UNDEFINED_PROPERTY,
    MI_STR_ID_ERROR_DETAILS,
    MI_STR_ID_ERROR_DETAILS_INCLUDED_FILE,
    MI_STR_ID_ERROR_DETAILS_CONTENT,
    MI_STR_ID_UNDEFINED_INSTANCE_ALIAS,
    MI_STR_ID_CONVERT_PROPERTY_VALUE_FAILED,
    MI_STR_ID_MI_CREATEINSTANCE_FAILED,
    MI_STR_ID_MI_SET_PROPERTY_FAILED,
    MI_STR_ID_MI_ADD_PROPERTY_FAILED,
    MI_STR_ID_ALIAS_DECL_ALREADY_DEFINED,

    MI_STR_ID_SYNTAX_ERROR_INVALID_ALIAS_DECL,
    MI_STR_ID_SYNTAX_ERROR_INVALID_COMMENT,
    MI_STR_ID_SYNTAX_ERROR_INVALID_TOKEN,
    MI_STR_ID_SYNTAX_ERROR_INCOMPLETE_STRING_VALUE,
    MI_STR_ID_SYNTAX_ERROR_INVALID_CHAR16_VALUE,
    MI_STR_ID_SYNTAX_ERROR_INVALID_ESCAPED_CHAR16_VALUE,
    MI_STR_ID_SYNTAX_ERROR_INVALID_ESCAPED_CHAR,
    MI_STR_ID_SYNTAX_ERROR_INCOMPLETE_ESCAPED_CHAR16_VALUE,
    MI_STR_ID_SYNTAX_ERROR_INVALID_NUMBER_VALUE,

    MI_STR_ID_CREATE_PARSER_FAILED,

    MI_STR_ID_PARAMETER_INVALID_OPTIONS_VALUE,
    MI_STR_ID_PARAMETER_INVALID_VALUE_STRING,
    MI_STR_ID_PARAMETER_INVALID_VALUE_NULL,
    MI_STR_ID_PARAMETER_INVALID_VALUE_UNEXPECTED_INTEGER,
    MI_STR_ID_PARAMETER_INVALID_VALUE_OUT_OF_RANGE_INTEGER,
    MI_STR_ID_PARAMETER_INVALID_BUFFER,

    MI_STR_ID_MI_CREATECLASS_FAILED,

    MI_STR_ID_PARAMETER_UNEXPECTED_RESULTCLASSCOUNT,
    MI_STR_ID_PARAMETER_UNEXPECTED_RESULTINSTANCECOUNT,

    MI_STR_ID_INVALID_EMBEDDEDPROPERTYVALUE_WRONG_TYPE,
    MI_STR_ID_INITIALIZER_OUT_OF_RANGE_DATETIMEVALUE,
};

MI_CONST size_t cSTRSLength = sizeof(cSTRS) / sizeof(cSTRS[0]);

/******************************************************************************
 * Load string
 *****************************************************************************/
MI_Char* GetString(MI_Uint32 id)
{
    if (id < cSTRSLength)
    {
        return cSTRS[id];
    }
    return NULL;
}

_Post_z_ MI_Char* mof_LookupString(
    MI_Uint32 id,
    _Out_writes_z_(len) MI_Char *buffer,
    size_t len)
{
    MI_UNREFERENCED_PARAMETER(len);
    buffer[0] = 0;
    return GetString(id);
}
